package ru.papergames.model.binsocket.packets.response
{
	import flash.geom.Rectangle;
	import ru.papergames.model.vo.BallVO;
	import ru.papergames.model.vo.PositionVO;
	
	import ru.papergames.model.binsocket.data.ExtByteArray;
	import ru.papergames.model.binsocket.packets.SocketResponse;

	public class BattleNewBallsThrownResponse extends SocketResponse
	{		
		public static const NOTIFICATION:String = 'BattleNewBallsThrownResponse';
		
		public var battleOrderId:uint;		
		public var balls:Array;
		
		public function BattleNewBallsThrownResponse(bytes:ExtByteArray)
		{
			super(bytes);
		}
		
		override protected function decode():void {
			
			battleOrderId = binaryData.readUnsignedInt();
			
			var ballsCount:uint = binaryData.readUnsignedShort();			
			balls = [];
			
			while (binaryData.bytesAvailable > 0 && ballsCount-- > 0) {
				var ball:BallVO = new BallVO();
			
				ball.position = new PositionVO( binaryData.readUnsignedShort(), binaryData.readUnsignedShort() );
				ball.coloreId = binaryData.readUnsignedShort();
				
				balls.push(ball);
			}
		}
		
		override public function getNotification():String {
			return NOTIFICATION;
		}
	}
}